# -*- coding: utf-8 -*-

'''eof
name:性别
code:Gender
tableName:
columnName:
groups:个人通用
dependencies:EG_DSJ
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

'''
年龄:
    从身份证号码中提取第17位数字，如果是奇数，则为男，若是偶数则是女
    legalPersonIdCard:身份证
'''

def Gender():
    null_type_list = ['', None, 'null', '/', 'Null']
    try:
        if ratingRequest['legalPersonIdCard'] not in null_type_list and \
                len(ratingRequest['legalPersonIdCard']) == 18 :
            if int(ratingRequest['legalPersonIdCard'][16])%2 == 1 :
                return u'男性'
            else:
                return u'女性'
        else:
            return u'缺失值'

    except:
        return u'缺失值'

result = Gender()